<?php

/**
 * This is the model class for table "{{products}}".
 *
 * The followings are the available columns in table '{{products}}':
 * @property string $pid
 * @property string $ptitle
 * @property string $pcover
 * @property string $pcontent
 * @property string $padd_time
 * @property string $pedit_time
 * @property string $padmin
 * @property string $pprice
 * @property string $pnumber
 * @property integer $pishot
 * @property string $pselled
 * @property string $ptype
 * @property string $plikes
 */
class Products extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Products the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{products}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ptitle, pcover, pcontent, padd_time, pedit_time, padmin, pprice, pnumber', 'required'),
			array('pishot', 'numerical', 'integerOnly'=>true),
			array('ptitle, pcover', 'length', 'max'=>256),
			array('padd_time, pedit_time, pprice, pnumber, pselled, ptype, plikes', 'length', 'max'=>10),
			array('padmin', 'length', 'max'=>25),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('pid, ptitle, pcover, pcontent, padd_time, pedit_time, padmin, pprice, pnumber, pishot, pselled, ptype, plikes', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'pid' => 'Pid',
			'ptitle' => 'Ptitle',
			'pcover' => 'Pcover',
			'pcontent' => 'Pcontent',
			'padd_time' => 'Padd Time',
			'pedit_time' => 'Pedit Time',
			'padmin' => 'Padmin',
			'pprice' => 'Pprice',
			'pnumber' => 'Pnumber',
			'pishot' => 'Pishot',
			'pselled' => 'Pselled',
			'ptype' => 'Ptype',
			'plikes' => 'Plikes',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('pid',$this->pid,true);
		$criteria->compare('ptitle',$this->ptitle,true);
		$criteria->compare('pcover',$this->pcover,true);
		$criteria->compare('pcontent',$this->pcontent,true);
		$criteria->compare('padd_time',$this->padd_time,true);
		$criteria->compare('pedit_time',$this->pedit_time,true);
		$criteria->compare('padmin',$this->padmin,true);
		$criteria->compare('pprice',$this->pprice,true);
		$criteria->compare('pnumber',$this->pnumber,true);
		$criteria->compare('pishot',$this->pishot);
		$criteria->compare('pselled',$this->pselled,true);
		$criteria->compare('ptype',$this->ptype,true);
		$criteria->compare('plikes',$this->plikes,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}